package com.bdqn.day0916.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author:Corday
 * @Date:2021/09/16/9:36
 */
@Controller
public class ExceptionController {
    @RequestMapping("/info/{lv}")
    public String go(@PathVariable("lv") int level, Model model){
        //跳转到正确的页面
        //int rs=level/0;
        int sum=100+level;
        //model.addAttribute("rs",rs);
        model.addAttribute("rs",sum);
        //如果程序没有错误 ，则跳转到info.html
        //如果有错，则跳转到异常管理的页面error.html中
        //实际跳转http://localhost:8080/templates/page/info.html
        return "page/info";
    }
//    请求之二
    @RequestMapping("/play")
    @ResponseBody
    public  String play(){
        int[] arr={19,13,15};
        //数组越界
        return "拿到："+arr[2];
    }
}
